﻿using Hicap.QRCodeWarehouse.Processor.Manager;
using Hicap.QRCodeWarehouse.Processor.Model;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using MongoDB.Driver;

namespace Hicap.QRCodeWarehouse.Processor.Controllers
{
    public class HealthController : Controller
    {
        private readonly IMonitorManager _monitorManager;

        public HealthController(IMonitorManager monitorManager)
        {
            _monitorManager = monitorManager;
        }

        [HttpGet]
        [AllowAnonymous]
        public IActionResult Check()
        {
            _monitorManager.GetCollection<WarhouseMonitor>("WarhouseMonitor").CountDocuments(x => !string.IsNullOrEmpty(x.ProductCode));

            return Ok();
        }
    }
}